package cn.weiyang.biz;

import cn.weiyang.dao.UsersDao;
import cn.weiyang.entity.Users;
import cn.weiyang.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * Created by Administrator on 2017/7/6.
 */
public class UsersBizImpl implements UsersBiz{
    /**
     * 用户注册
     * @param users
     * @return
     */
    public int reg(Users users) {
        SqlSession session=SqlSessionFactoryUtil.getSqlSession();
        UsersDao ud=session.getMapper(UsersDao.class);
        int res=ud.reg(users);
        session.commit();
        session.close();
        return res;
    }

    /**
     * 用户登录
     * @param users
     * @return
     */
    public Users login(Users users) {
        SqlSession session=SqlSessionFactoryUtil.getSqlSession();
        UsersDao ud=session.getMapper(UsersDao.class);
        Users users1=ud.login(users);
        session.close();
        return users1;
    }
}
